#include <DocumentContainer>
#include <Document>

DocumentContainer::DocumentContainer(QObject *parent) :
    QObject(parent)
{
}

QPointer<Document> DocumentContainer::createDocument()
{
    QPointer<Document> doc = new Document;
    m_documents.append(doc);
    return doc;
}

void DocumentContainer::setActiveDocument(QPointer<Document> doc)
{
    emit currentDocumentAboutToChange();
    m_activeDocument = doc;
    emit currentDocumentChanged();
}

QPointer<Document> DocumentContainer::activeDocument() const
{
    return m_activeDocument;
}

const DocumentList &DocumentContainer::documents() const
{
    return m_documents;
}

void DocumentContainer::removeDocument(QPointer<Document> doc)
{
    if(m_documents.contains(doc))
    {
        m_documents.removeOne(doc);
    }
}
